{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Imports"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import quiz_tests"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Quiz Solution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def days_to_weeks(open_prices, high_prices, low_prices, close_prices):\n",
    "    \"\"\"Converts daily OHLC prices to weekly OHLC prices.\n",
    "    \n",
    "    Parameters\n",
    "    ----------\n",
    "    open_prices : DataFrame\n",
    "        Daily open prices for each ticker and date\n",
    "    high_prices : DataFrame\n",
    "        Daily high prices for each ticker and date\n",
    "    low_prices : DataFrame\n",
    "        Daily low prices for each ticker and date\n",
    "    close_prices : DataFrame\n",
    "        Daily close prices for each ticker and date\n",
    "\n",
    "    Returns\n",
    "    -------\n",
    "    open_prices_weekly : DataFrame\n",
    "        Weekly open prices for each ticker and date\n",
    "    high_prices_weekly : DataFrame\n",
    "        Weekly high prices for each ticker and date\n",
    "    low_prices_weekly : DataFrame\n",
    "        Weekly low prices for each ticker and date\n",
    "    close_prices_weekly : DataFrame\n",
    "        Weekly close prices for each ticker and date\n",
    "    \"\"\"\n",
    "    \n",
    "    # TODO: Implement Function\n",
    "    \n",
    "    open_prices_weekly = open_prices.resample('W').first()\n",
    "    high_prices_weekly = high_prices.resample('W').max()\n",
    "    low_prices_weekly = low_prices.resample('W').min()\n",
    "    close_prices_weekly = close_prices.resample('W').last()\n",
    "    \n",
    "    return open_prices_weekly, high_prices_weekly, low_prices_weekly, close_prices_weekly\n",
    "\n",
    "\n",
    "quiz_tests.test_days_to_weeks(days_to_weeks)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
